package com.lifp.service.impl;

import com.lifp.service.MessageService;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

/**
 * @Description TODO
 * @Author lfp
 * @Date 2022/7/22
 * @Version 1.0
 */
@Slf4j
@Service
public class MessageServiceImpl implements MessageService {
    @SneakyThrows
    @Override
    public String syncSendMessage() {
        log.info("开始同步请求......");

        //休眠5秒，模拟耗时操作
        Thread.sleep(5000);

        log.info("同步消息推送成功......");

        return "sync success";
    }

    @Async
    @SneakyThrows
    @Override
    public String asyncSendMessage() {
        log.info("开始异步请求......");
        //休眠5秒，模拟耗时操作
        Thread.sleep(5000);

        log.info("异步消息推送成功......");
        return "async success";
    }
}
